<template>
  <div class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('申请单') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('流水号') }}</td>
        <td>{{ form.serialNumber }}</td>
        <td class="tit">{{ $t('开放控制') }}</td>
        <td>
          <dict-select
            v-model="form.openControl"
            dictionary="open_control"
            :placeholder="$t('开放控制')"
          />
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('密级') }}</td>
        <td>
          <dict-select
            v-model="form.securityClassification"
            dictionary="security_classification"
            :placeholder="$t('密级')"
          />
        </td>
        <td class="tit">{{ $t('缓急') }}</td>
        <td>
          <dict-select
            v-model="form.gradual"
            dictionary="gradual"
            :placeholder="$t('缓急')"
          />
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('登记号') }}</td>
        <td>{{ form.registrationNumber }}</td>
        <td class="tit">{{ $t('收文日期') }}</td>
        <td>{{ parseTime(form.dateReceipt) }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('主送领导') }}</td>
        <td colspan="3">
          <UserSelect
            v-model="form.mainLead"
          />
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('文件标题') }}</td>
        <td>{{ form.actTitle }}</td>
        <td class="tit">{{ $t('文号') }}</td>
        <td>{{ form.referenceNumber }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('来文单位') }}</td>
        <td>{{ form.jeremyLevinUnit }}</td>
        <td class="tit">{{ $t('主办') }}</td>
        <td>
          <UserSelect v-model="form.hostUserId" />
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('协办') }}</td>
        <td>
          <UserSelect v-model="form.jointlyUserId" multiple />
        </td>
        <td class="tit">{{ $t('传阅') }}</td>
        <td>
          <UserSelect v-model="form.circulateUserId" multiple />
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('办理期限') }}</td>
        <td>
          <el-date-picker
            v-model="form.dealWithTime"
            clearable
            style="width: 200px"
            type="datetime"
            value-format="yyyy-MM-dd hh:mm:ss"
          />
        </td>
        <td class="tit">{{ $t('复文时间') }}</td>
        <td>
          {{ parseTime(form.fuwenTime) }}
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('签报时间') }}</td>
        <td>
          {{ parseTime(form.signAtTime) }}
        </td>
        <td class="tit">{{ $t('督办时间') }}</td>
        <td>
          {{ parseTime(form.overseeTheTime) }}
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('备注') }}</td>
        <td colspan="3">{{ form.remark }}</td>
      </tr>
    </table>
    <!-- 附件列表 -->
    <FileView :list.sync="form.fileList" data-type="oa_addressee" :btn-show="!otherBtnHide" />
  </div>
</template>

<script>
  import { getOaAddressee } from '@/api/oa/addressee/oaAddressee'
  export default {
    name: 'OaAddresseeForm',
    components: {
    },
    data() {
      return {
        openLocation: undefined,
        // 是否隐藏保存按钮
        btnHide: false,
        // 是否隐藏其它按钮
        otherBtnHide: false,
        // 表单参数
        form: {
          // 附件列表
          fileList: []
        },
        // 遮罩层
        loading: false,
        // 操作按钮默认不展示
        buttonShow: true,
        // 流程状态字典
        actStatusOptions: [],
        openControlOptions: [],
        securityClassificationOptions: [],
        gradualOptions: [],
        // 协办
        jointlyUserIdOptions: []
      }
    },
    created() {
      this.getDicts('open_control').then(response => {
        this.openControlOptions = response.data
      })
      this.getDicts('security_classification').then(response => {
        this.securityClassificationOptions = response.data
      })
      this.getDicts('gradual').then(response => {
        this.gradualOptions = response.data
      })
      this.getDicts('work_flow_status').then(response => {
        this.actStatusOptions = response.data
      })
      this.$bus.$emit('async_done')
    },
    methods: {
      // 初始化数据
      init(data) {
        this.loading = true
        if (data != null && data.id !== undefined && data.id !== '' && data.id !== null) {
          this.buttonShow = false
          // 根据ID查询数据
          getOaAddressee(data.id).then(response => {
            this.form = response.data
            // getNickName(this.form.jointlyUserId).then(response => {
            //   this.jointlyUserIdOptions = response.msg
            // })
            this.loading = false
          })
        }
      }
    }
  }
</script>
